/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufrgs.inf.prav.jsf.components;

import java.io.IOException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

/**
 *
 * @author Fernando Arena Varella
 * @version 1.0
 */
public class AComponent extends PravBaseComponent {

    public static final String COMPONENT_FAMILY = "PRAV_A";
    public static final String COMPONENT_TYPE = "PRAV_A";

    //attributes
    private String charset, coords, href, hreflang, name, rel, rev, shape, target, type;

    public AComponent(){

    }

    @Override
    public void encodeBegin(FacesContext context) throws IOException {
        if (!displayPlataform())
            return;

		ResponseWriter writer =
			context.getResponseWriter();
		writer.startElement("a", this);

        //fix href att
        href = makeFinalReference(href);

        //atts
        writer.writeAttribute("charset", charset, "charset");
        writer.writeAttribute("coords", coords, "coords");
        writer.writeAttribute("href", href, "href");
        writer.writeAttribute("hreflang", hreflang, "hreflang");
        writer.writeAttribute("name", name, "name");
        writer.writeAttribute("rel", rel, "rel");
        writer.writeAttribute("rev", rev, "rev");
        writer.writeAttribute("shape", shape, "shape");
        writer.writeAttribute("target", target, "target");
        writer.writeAttribute("type", type, "type");

        addBaseAttributes(writer);

        String value = super.getValue();
        if (value != null)
            writer.write(super.getValue());

        writer.flush();

	}

    @Override
    public void encodeEnd(FacesContext context)
            throws IOException {
        if (!displayPlataform())
            return;
        ResponseWriter writer = context.getResponseWriter();
        writer.endElement("a");
        writer.flush();
//        return;
    }

    @Override
    public void decode(FacesContext context) {
    }



    // <editor-fold defaultstate="collapsed" desc="Getters And Setters">

    public String getCharset() {
        return charset;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public String getCoords() {
        return coords;
    }

    public void setCoords(String coords) {
        this.coords = coords;
    }

    public String getHref() {
        return href;
    }

    public void setHref(String href) {
        this.href = href;
    }

    public String getHreflang() {
        return hreflang;
    }

    public void setHreflang(String hreflang) {
        this.hreflang = hreflang;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRel() {
        return rel;
    }

    public void setRel(String rel) {
        this.rel = rel;
    }

    public String getRev() {
        return rev;
    }

    public void setRev(String rev) {
        this.rev = rev;
    }

    public String getShape() {
        return shape;
    }

    public void setShape(String shape) {
        this.shape = shape;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
    // </editor-fold>

}
